<%@ page language="java" import="java.util.*, java.text.*,com.zjut.zs.util.tools.*,com.zjut.an.util.tools.*,com.zjut.an.util.system.*,
com.zjut.zs.user.manager.*, com.zjut.zs.user.dao.*,com.zjut.zs.file.manager.*, com.zjut.zs.file.dao.*,com.zjut.zs.school.manager.*, com.zjut.zs.school.dao.*,com.zjut.zs.shhd.manager.*, com.zjut.zs.shhd.dao.*,
com.zjut.zs.userstatus.manager.*, com.zjut.zs.userstatus.dao.*,com.zjut.an.config.manager.*, com.zjut.an.config.dao.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">  
<meta name="renderer" content="webkit"> 
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/plugins/webupload/css/upload/upload.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/plugins/webupload/plugin/ueditor/third-party/webuploader/webuploader.css">				
<script type="text/javascript" src="../plugins/assets/plugins/jquery-3.5.1.min.js"></script>
<script src="<%=request.getContextPath() %>/plugins/webupload/plugin/ueditor/third-party/webuploader/webuploader.min.js"></script>
</head>

<body>
<jsp:include page="zs_uservalidate.jsp" flush="true"/>
<%
if (session.getAttribute("zsUser") == null&&session.getAttribute("admin") == null&&session.getAttribute("user") == null) {
	out.print("<script>alert('由于长时间未操作，系统已经自动注销，请重新登陆');</script>");
	out.print("<script>top.window.location='main.jsp';</script>");
} else {
ZsSchoolManager zsManager = (ZsSchoolManager) SpringContextUtil.getBean("ZsSchoolManager");
ZsSchool school = new ZsSchool();
school = (ZsSchool)zsManager.getDataByInstance(1,1,null,null,school).getObjects().get(0);
if(Status.ON_NOFILE.getStatus().equals(school.getScShhdActive())){ //是否上传
	out.print("<script>window.location='zs_shhd_2.jsp';</script>");
	out.close();
	return;
}
AnConfigManager anconfig = (AnConfigManager) SpringContextUtil.getBean("AnConfigManager");
ZsHTMLCreat html = (ZsHTMLCreat) SpringContextUtil.getBean("ZsHTMLCreat");
ZsShhdManager xmanager = (ZsShhdManager) SpringContextUtil.getBean("ZsShhdManager");
ZsUserManager umanager = (ZsUserManager) SpringContextUtil.getBean("ZsUserManager");
ZsUserStatusManager smanager = (ZsUserStatusManager) SpringContextUtil.getBean("ZsUserStatusManager");
ZsFileManager fmanager = (ZsFileManager) SpringContextUtil.getBean("ZsFileManager");
ZsShhd shhd = new ZsShhd();
ZsUser user = null;
ZsFile file = new ZsFile();
List flist = new ArrayList();
if(session.getAttribute("admin")!=null && request.getParameter("usId")!=null) {
	int usId = Integer.parseInt(request.getParameter("usId"));
	user = umanager.getData(usId);
} else if (session.getAttribute("zsUser")!=null) {
	user = (ZsUser)session.getAttribute("zsUser");	
} 
List list = new ArrayList();
if (user!=null) {
	shhd.setZsUser(user);
	list = xmanager.getDataByInstance(1,100,null,null,shhd).getObjects();
}

if(request.getParameter("hdId")!=null) {
	shhd = xmanager.getData(Integer.parseInt(request.getParameter("hdId")));					
}	
ZsUserStatus userStatus = smanager.getDataByUser(user);
boolean edit=false;//允许编辑
if(Status.SENDSTATUS_NULL.getStatus().equals(userStatus.getSendStatus()) || Status.SENDSTATUS_NO.getStatus().equals(userStatus.getSendStatus()))edit=true;

 %>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="index.jsp">首页</a></li>
    <li><a href="#">社会活动情况</a></li>
    </ul>		
    </div>
    
   <%if (session.getAttribute("admin") != null) {%>
   <div  class="imgrotatebutton"><a href='../admin/zsImgRotate.jsp?fiType=shhd&usId=<%=user.getUsId() %>' target='_blank'>批量浏览模式(切换、放大、翻转)</a></div>
   <%} %>
   
    <form id="ff" name="add" role="form" class="form-horizontal" action="" method="post">
    <div class="formbody">    
	    <div class="rightinfo">
		    <table class="imgtable">
		    
		    <thead>
		    <tr>
		    <th>活动名称</th>
		    <th>担任角色</th>
		    <th>活动时间</th>
		    <th>组织单位</th>
		    <th>佐证材料</th>
		    <th>操作</th>
		    </tr>
		    </thead>
		    
		    <tbody>
		    <%
		    for (int i=0; i<list.size(); i++){
		    	ZsShhd obj = (ZsShhd)list.get(i);
		     %>
		    <tr>
		    <td><%=obj.getHdName() %></td>
		    <td><%=obj.getHdJs() %></td>
		    <td><%=obj.getHdDateStart() %>至<%=obj.getHdDateEnd() %></td>
		    <td><%=obj.getHdOrg() %></td>
		    <%-- <td><a href='<%=obj.getHdFiles() %>' target='_blank'>材料</a></td> --%>
		    <td>
		    <%
		    file.setZsUser(user);
			file.setFiName(obj.getHdId()+"");	
			file.setFiType("shhd");
			flist = fmanager.findByExample(file);
			 for (int j=0; j<flist.size(); j++){
			 ZsFile fi = (ZsFile)flist.get(j);
		    %>
		    <a href='<%=fi.getFiFile() %>' target='_blank'>材料<%=j %></a>
		     <%} %>
		     </td>
		    <td>
		    <%if(edit){ %>
		    <a href="zs_shhd.jsp?hdId=<%=obj.getHdId()%>" class="tablelink">编辑</a>　
			<a href="#" onclick="javascript:deleteobj('<%=obj.getHdId() %>');">删除</a>
		    <%} %>
		    </td>
		    <% }  %>
		    
		    </tbody>
		    </table>
	    
	    	<br>
		     
		    <%if(edit){ %>
			<form id="ff" name="add" role="form" class="form-horizontal" action="" method="post">
			    <div id="container" style="width:96%;margin:0 auto;">
			    <table id="hdtable" class="imgtable" >
			    <thead>
			    <tr>
			    <th>活动名称</th>
			    <th>担任角色</th>
			    <th>活动开始时间</th>
			    <th>活动结束时间</th>
			    <th>组织单位</th>
			    <th>佐证材料</th>
			    </tr>
			    </thead>
			    
			    <tbody>
			    <tr>
			    <td style="text-indent: 5px;"><input id="hdName" name="hdName" type="text" class="dfinput" value="<%=html.getInputString(shhd.getHdName()) %>" required style="width: 100px"/></td>
			    <td style="text-indent: 5px;"><input id="hdJs" name="hdJs" type="text" class="dfinput" value="<%=html.getInputString(shhd.getHdJs()) %>" style="width: 100px"/></td>
			    <td style="text-indent: 5px;"><input id="hdDateStart" name="hdDateStart" type="text" class="dfinput" value="<%=html.getInputString(shhd.getHdDateStart()) %>" style="width: 100px"/></td>
			    <td style="text-indent: 5px;"><input id="hdDateEnd" name="hdDateEnd" type="text" class="dfinput" value="<%=html.getInputString(shhd.getHdDateEnd()) %>" style="width: 100px"/></td>
			    <td style="text-indent: 5px;"><input id="hdOrg" name="hdOrg" type="text" class="dfinput" value="<%=html.getInputString(shhd.getHdOrg()) %>" required style="width: 200px"/></td>
			    <td style="text-indent: 5px;">
			    <%-- <%if(null!=shhd.getHdFiles() && shhd.getHdFiles().trim().length()>0){ %>
			    <a href='<%=shhd.getHdFiles() %>' target='_blank'>材料</a>
			    <%} %> --%>
			     <%
							    if(null!=shhd.getHdId()){
		    						file.setZsUser(user);
									file.setFiName(shhd.getHdId()+"");	
									file.setFiType("shhd");
									flist = fmanager.findByExample(file);
			 						for (int j=0; j<flist.size(); j++){
									ZsFile fi = (ZsFile)flist.get(j);
		    					%>
		    						<a href='<%=fi.getFiFile() %>' target='_blank'>材料<%=j %></a>
		     						<%} %>
							    <%} %>
				<a id="selectfiles" href="javascript:void(0);" class="ibtn" style="float:right;margin:5px;"><img src="images/iadd.png" style="margin:5px;"/>添加文件</a>		    
			    </td>
			    </tr>
			    </tbody>
			    </table>
			    <input name="hdFiles" type="text" id="hdFiles" value="<%=html.getInputString(shhd.getHdFiles()) %>"  class="dfinput"  style="display:none;"/>  	
					<input id="hdId" name="hdId" type="text" class="dfinput" value="<%if(null==shhd.getHdId()){out.print("");}else{out.print(shhd.getHdId());}; %>" style="display:none;"/>
			    	<input id="zsUser.usId" name="zsUser.usId" type="text" class="dfinput" value="<%=shhd.getZsUser().getUsId()%>" style="display:none;"/>
					<div id="uploaderfile" class="wu-example">
					    <!--用来存放文件信息-->
					     待上传材料：
					    <div id="ossfile"></div>						
						<pre id="console"></pre>								
					    <div class="btns">								 
							<a id="postfiles" href="javascript:void(0);" class="btn btn-default" style="float:right;margin:10px;">确认保存</a>
						    <!--<a id="selectfiles" href="javascript:void(0);" class="btn" style="float:right;margin:10px;">选择文件</a>-->
					    </div>
					</div>
					<script type="text/javascript" src="lib/crypto1/crypto/crypto.js"></script>
					<script type="text/javascript" src="lib/crypto1/hmac/hmac.js"></script>
					<script type="text/javascript" src="lib/crypto1/sha1/sha1.js"></script>
					<script type="text/javascript" src="lib/base64.js"></script>
					<script type="text/javascript" src="lib/plupload-2.1.2/js/plupload.full.min.js"></script>
					<script type="text/javascript" src="<%=request.getContextPath() %>/plugins/webupload/scripts/upload/ossshhdupload.js"></script> 
				</div> 
		    </form>
		    <%} %>
	    </div>
    
    
    </div>


</form> 
<div style="margin:50px;"><%out.print(anconfig.getSingleConfigInfoByName("社会活动填写需知")); %></div>


<script src="../plugins/assets/plugins/jquery-3.5.1.min.js" type="text/javascript"></script>  
<script src="../plugins/assets/plugins/jquery-validation-1.14.0/dist/jquery.validate.js" type="text/javascript"></script>
<script src="../plugins/assets/plugins/jquery-validation-1.14.0/dist/jquery.metadata.js" type="text/javascript"></script>
<script src="js/formvalidate.js" type="text/javascript"></script>
<script src="../admin/js/publicManager.js" type="text/javascript" charset="utf-8"></script> 

		<script type="text/javascript">
		var updateOneAction = '../zsShhdSave.action?randnum='+Math.floor(Math.random()*1000000);
			var loactionurl = 'zs_shhd.jsp';
			
		$(function(){
		    //jquery.validate
			$("#ff").validate({
				submitHandler: function() {
					//验证通过后 的js代码写在这里
					submitFormAdvance();
				}
			})				
		})
		
		$('.imgtable tbody tr:odd').addClass('odd');
		
		function deleteobj(hdId) {
			if (confirm("是否确认"))  { 
				$.get("../zsShhdDelete.action?randnum="+Math.floor(Math.random()*1000000)+"&hdId="+hdId, function(data){
					if(data.flag=="success"){
						alert("删除成功！");
						window.location = loactionurl;
					}else{
						alert("删除失败！");
					}
				}); 
			}
		}
		</script>
		<script src="js/laydate.dev.js" type="text/javascript"></script>
		<script type="text/javascript">			
			laydate({
				elem: document.getElementById("hdDateStart")
			});
			laydate({
				elem: document.getElementById("hdDateEnd")
			});
		</script>
		
<%} %>		
</body>

</html>
